#!/bin/bash

CC=`which gcc` -O3

all: 928codes 928lib
928codes: 
	@echo "...BUILDING 928CODES"
	$(CC) -o ./928codes ./src/928codes.c ./src/928paint.c ./src/928options.c
	@echo "...DONE"
928lib:
	@echo "...BUILDING 928LIB"
	$(CC) -D_928LIB_ -I`pwd`/src -fPIC -shared -o ./928codes.so ./src/928codes.c ./src/928paint.c ./src/928options.c
	$(CC) -c -D_928LIB_ -I`pwd`/src -o ./src/928codes.o ./src/928codes.c 
	$(CC) -c -D_928LIB_ -I`pwd`/src -o ./src/928paint.o ./src/928paint.c 
	$(CC) -c -D_928LIB_ -I`pwd`/src -o ./src/928options.o ./src/928options.c
	ar rc ./928codes.a ./src/928codes.o ./src/928paint.o ./src/928options.o
	ranlib ./928codes.a
	@echo "...DONE"
clean: 
	@echo "...CLEANING BUILD"
	`which rm` -f ./src/*~ ./src/*.o ./928codes ./*~ ./*.so ./*.a
	@echo "...DONE"
install: 
	@echo "...INSTALLING TO /usr/local/bin"
	`which install` ./928codes /usr/local/bin
	@echo "...DONE"
